﻿@using SmartSiteManagementSystem.Models.User;
@using SmartSiteManagementSystem.IServices;
@inject IMaterialService _materialService
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.BodyClass = "easyui-layout";
    UserInfo userInfo = ViewBag.userInfo;
}
    <div class="easyui-panel" style="padding:5px;">    
        <input id="UserId" type="hidden" value="@userInfo.UserId" />
        <table class="gou-formTable" style="align-content:center;">
            <tbody>              
                <tr>
                    <td align="right" class="gou-formTable-title" style="width:160px;">*登录名:</td>
                    <td align="left" class="">
                         <input id="LogonName" name="LogonName" type="text" value="@userInfo.LogonName" @if(userInfo.UserId>0){@Html.Raw(" readonly=readonly")} />    
                    </td>
                </tr>
                <tr>
                    <td align="right" class="gou-formTable-title"></td>
                    <td align="left" class=""><font style="color:red">*登录密码默认666666</font></td>

                </tr>
                @if(userInfo.UserId>0){
               <tr>
                    <td align="right" class="gou-formTable-title"></td>
                    <td align="left" class=""><font style="color:red">*创建时间：@userInfo.CreateTime 创建类型: @userInfo.RegTypeName<br/>
                        最后登陆时间:@userInfo.LastestLogonTime  最后登陆IP:@userInfo.LastestLogonIp </font></td>

                </tr>
                }
            <tr>
                <td align="right" class="gou-formTable-title"><font style="color:red;">*</font>岗位：</td>
                <td align="left"> <select id="PositionType" class="easyui-combobox" name="PositionType" style="width:200px;" panelheight="200px">
                                    <option value="0">请选择</option>
                                    <option value="1">塔吊司机</option>
                                </select> </td>
            </tr> 

            <tr>
                <td align="right" class="gou-formTable-title"><font style="color:red;">*</font>姓名：</td>
                <td align="left"> <input id="ShowName" name="ShowName" type="text" value="@userInfo.ShowName" /> </td>
            </tr>   
            <tr>
                <td align="right" class="gou-formTable-title" style="width:157px;"><span style="color:red">*</span>商品素材类型：</td>
                <td align="left" class="" >
                    <input type="radio" value="1" checked="checked" name="Sex" @if (userInfo.Sex==1) { <text> checked="checked" </text>                                          } />男
                    <input type="radio" value="2" name="Sex" @if (userInfo.Sex == 2) { <text> checked="checked" </text>                                          } />女
                </td>
            </tr>
             <tr>
                    <td align="right" class="gou-formTable-title">Email:</td>
                    <td align="left" class="">                        
                        <input id="Email" name="Email" type="text" value="@userInfo.Email" /> 
                    </td>
            </tr>
                         <tr>
                    <td align="right" class="gou-formTable-title">手机号:</td>
                    <td align="left" class="">                        
                        <input id="Mobile" name="Mobile" type="text" value="@userInfo.Mobile" /> 
                    </td>
            </tr>

                <tr>
                    <td colspan="2" align="center">                       
                            <a href="javascript:void(0)" id="hfSave" class="easyui-linkbutton" iconcls="icon-save" onclick="SaveUser();" style="width:150px;height:32px">保存</a>                                           
                    </td>
                </tr>
            </tbody>
        </table>

    </div>



    <script type="text/javascript">        


        //保存
        function SaveUser() {

            //验证必选项******************************************************************
            var LogonName = $("#LogonName").val();
            if (LogonName == "") {
                $.messager.alert('提示', '登录名为必填项!');
                return false;
            }
             //岗位
             var PositionType = jQuery("[name=PositionType]").val();
             if (PositionType == 0) {
                    $.messager.alert('提示信息', "请选择岗位", 'info').panel('move', {
                        top: 100
                    });
                    return;
             }

            var ShowName= $("#ShowName").val();
            if (ShowName == "") {
                $.messager.alert('提示', '姓名为必填项!');
                return false;
            }


           var sex = $("input[name='Sex']:checked").val();
           if (sex == "") {
                $.messager.alert('提示', '请选择性别!');
                return false;
            }
            var Email=$("#Email").val();

            var Mobile= $("#Mobile").val();
            var UserId = $("#UserId").val();

            var param = { UserId: UserId, LogonName: LogonName,PositionType:PositionType, ShowName: ShowName, Sex: sex, Email: Email, Mobile: Mobile};
            $.ajax({
                "type": "Post",
                "url": "ajaxAccess?t=" + new Date().getTime(),
                "dataType": "text",
                "data": param,
                "success": function (data) {
                    if (data == 1) {
                        window.location.href = "index";
                    }
                    else if (data == -2)
                    {
                        $.messager.alert('提示', '登录名已存在!');
                    }
                    else
                    {
                        $.messager.alert('提示', '保存失败');
                    }
                }
            });
        }
</script>    
